<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        /* .demo {
      height: 100px;
      background: #eee;
    } */

        .parent {
            height: 200px;
            background: #88f;
            /* overflow: hidden; */
            /* 父元素设置overflow: hidden*/
            /* padding-top: 20px; */
            /* 父元素加上padding-top，这样的话，父元素的高度会发生变化，所以要取消子元素的margin-top*/
        }

        .child {
            height: 100px;
            margin-top: 20px;
            border: 1px solid transparent;
            background: #0ff;
            width: 200px;
        }
    </style>
</head>

<body>
    <!-- <section class="demo">
    <h2>此部分是能更容易看出让下面的块的margin-top。</h2>
  </section> -->
    <section class="parent">
        <article class="child">
            <h2>子元素</h2>
            margin-top:20px;
        </article>
        <h2>父元素</h2>
        没有设置margin-top
    </section>
</body>
<script>
    var b = 1;
    function outer() {
        var b = 2;
        function inter() {
            b++;
            var b = 3;
            console.log(b);

        }
        inter()
    }
    outer()
</script>

</html>